/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef PLELF_APPLICATION_HEADER_ENUMS_H
#define PLELF_APPLICATION_HEADER_ENUMS_H

namespace PLSDK {

/**
 * Elf application header enums.
 */
class PLELFApplicationHeaderEnums {
public:
	/**
	 * Constructor.
	 */
	inline PLELFApplicationHeaderEnums() {}
	/**
	 * The type of the application header.
	 */
	enum PType {
		/**
		 * The array element is unused; other members' values are undefined. This type
		 * lets the program header table have ignored entries.
		 */
		PTypeNull				= 0,
		/**
		 * The array element specifies a loadable segment, described by p_filesz and
		 * p_memsz. The bytes from the file are mapped to the beginning of the memory
		 * segment. If the segment's memory size (p_memsz) is larger than the file size
		 * (p_filesz), the ``extra'' bytes are defined to hold the value 0 and to follow the
		 * segment's initialized area. The file size may not be larger than the memory size.
		 * Loadable segment entries in the program header table appear in ascending order,
		 * sorted on the p_vaddr member.
		 */
		PTypeLoad				= 1,
		/**
		 * The array element specifies dynamic linking information.
		 */
		PTypeDynamic			= 2,
		/**
		 * The array element specifies the location and size of a null-terminated path name
		 * to invoke as an interpreter. This segment type is meaningful only for executable
		 * files (though it may occur for shared objects); it may not occur more than once in
		 * a file. If it is present, it must precede any loadable segment entry.
		 */
		PTypeInterpreter		= 3,
		/**
		 * The array element specifies the location and size of auxiliary information.
		 */
		PTypeNote				= 4,
		/**
		 * This segment type is reserved but has unspecified semantics. Programs that contain
		 * an array element of this type do not conform to the ABI.
		 */
		PTypeSheredLibrary	= 5,
		/**
		 * The array element, if present, specifies the location and size of the program header
		 * table itself, both in the file and in the memory image of the program. This segment
		 * type may not occur more than once in a file. Moreover, it may occur only if the program
		 * header table is part of the memory image of the program. If it is present, it must
		 * precede any loadable segment entry.
		 */
		PTypeHeaderTable		= 6,
		/**
		 * Values in this inclusive range are reserved for operating system-specific semantics.
		 */
		PTypeLoos				= 0x60000000,
		/**
		 * Values in this inclusive range are reserved for operating system-specific semantics.
		 */
		PTypeHiOS				= 0x6fffffff,
		/**
		 * Values in this inclusive range are reserved for processor-specific semantics. If meanings
		 * are specified, the processor supplement explains them.
		 */
		PTypeLoProcessor		= 0x70000000,
		/**
		 * Values in this inclusive range are reserved for processor-specific semantics. If meanings
		 * are specified, the processor supplement explains them.
		 */
		PTypeHiProcessor		= 0x7fffffff
	};
	/**
	 * A program to be loaded by the system must have at least one loadable segment (although this
	 * is not required by the file format). When the system creates loadable segments' memory
	 * images, it gives access permissions as specified in the p_flags member.
	 */
	enum PFlag {
		/**
		 * Execute.
		 */
		PFlagExecute			= 0x1,
		/**
		 * Write.
		 */
		PFlagWrite				= 0x2,
		/**
		 * Read.
		 */
		PFlagRead				= 0x4,
		/**
		 * All bits included in the PFlagMaskos mask are reserved for operating system-specific semantics.
		 */
		PFlagMaskos				= 0x0ff00000,
		/**
		 * All bits included in the PFlagMaskProcessor mask are reserved for processor-specific semantics.
		 * If meanings are specified, the processor supplement explains them.
		 */
		PFlagMaskProcessor	= 0xf0000000
	};
	PLDECLAREFLAGS(PFlags, PFlag);
};

}

#endif
